package com.zat.mes.andrmes.dofun.work.adapter

import android.content.Context
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.ImageView
import android.widget.TextView
import com.zat.mes.andrmes.R
import com.zat.mes.andrmes.data.ItemList

/**
 * @author zy
 * @date :2020-07-01 14:37
 * @description:做工记录 工序显示
 */
class DayWorkScanProcAdapter00(context:Context, list:MutableList<ItemList>): BaseAdapter() {
    var context = context
    var list:MutableList<ItemList> = list
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var viewHolder:ViewHolder? = null
        var view: View? = null
        if (convertView == null) {
            viewHolder = ViewHolder()
            view = LayoutInflater.from(context).inflate(R.layout.item_company, null)
            viewHolder.tv = view.findViewById(R.id.company_item)
            viewHolder.iv = view.findViewById(R.id.ivStatus_item_work)
            view.tag = viewHolder
        } else {
            view = convertView
            viewHolder = view.tag as ViewHolder
        }

        viewHolder.tv?.text = list?.get(position).procName
        if (!TextUtils.isEmpty(list?.get(position)?.finishTime)){
            viewHolder.iv?.visibility = View.VISIBLE
        }else{
            viewHolder.iv?.visibility = View.GONE
        }

        return view!!
    }

    override fun getItem(position: Int): Any {
        return list.get(position)
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getCount(): Int {
        return list.size
    }

    class ViewHolder{
        var tv:TextView? = null
        var iv:ImageView? = null
    }

}